{extend name="layouts/main" /}
{block name="main"}
<style>
    .type-item-active{
        padding-bottom: 2px;
        border-bottom: 2px solid #1A77C7;
    }
    .type-item-list{
        width: 120px;
        display: flex;
        justify-content: space-around;
    }
    .que-list{
        width: 80%;
        display: flex;
        flex-direction: column;
        margin:0 auto;
    }
    .que-item{
        padding:10px 0;
        display: flex;
        justify-content: space-between;
    }
    .que-title{
        width:50%;
        margin:0 auto;
        text-align: center;
        font-size: 16px;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card" style="padding:10px">
        <div class="type-item-list">
            <a class="{$dataType==0?'type-item-active':''}" href="/admin/questions/index?dataType=0">学生问卷</a>
            <a class="{$dataType==1?'type-item-active':''}" href="/admin/questions/index?dataType=1">教师问卷</a>
        </div>
        <div class="main-container">
            <div class="que-title">{$dataType==0?"学生评教问卷":"教师评教问卷"}</div>
            <div class="que-list" id="reviewDiv">
                {volist name="questions" id="item" key="key"}
                <div class="que-item">{$key}、{$item.qu_msg}【{$item.qu_score}分】</div>
                {/volist}
            </div>
            <form id="editForm" action="/admin/questions/editSave" method="post">
                <div class="que-list" style="display: none" id="editDiv">
                    {volist name="questions" id="item" key="key"}
                    <div class="que-item">
                        <input type="text" style="width:78%" class="layui-input" name="qu_msg[]" value="{$item.qu_msg}"/>
                        <input type="hidden" name="qu_id[]" value="{$item.id}"/>
                        <div style="width:20%;display: flex;align-items: center">
                            <input type="text" class="layui-input" name="qu_score[]" value="{$item.qu_score}"/><span>分</span>
                        </div>
                    </div>
                    {/volist}
                </div>
                <div style="display: flex;justify-content: center">
                    <input type="hidden" name="dataType" value="{$dataType}"/>
                    <input type="hidden" id="editStatus" value="0"/>
                    <input type="button" class="layui-btn" onclick="editData(this)" value="修改"/>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use('layer', function(){
        var layer = layui.layer;
    });

    function editData(obj){
        let editStatus=$("#editStatus").val();
        if(editStatus==0){
            $("#editDiv").show();
            $("#reviewDiv").hide();
            $("#editStatus").val(1);
            $(obj).val("保存");
        }else{
            $("#editForm").submit();
        }

    }
</script>
{/block}
